<script setup lang="ts">
import axios from "axios";
import {onMounted, ref} from "vue";;
import {useRouter} from "vue-router";
import myAxios from "@/plugins/myAxios.ts";
import {getCurrentUser} from "@/services/user.ts";
import type {userType} from "@/model/user";
import {getCurrentUser2} from "@/services/user2.ts";

const user = ref<userType>();

;
//验证码
const generateRandomCode = () => {
  return Math.floor(100000 + Math.random() * 900000);
};

onMounted(async () => {
  const res = await getCurrentUser();
  // @ts-ignore
  if (res?.code === 40100 || res.data == null) {
    router.push({
      path: '/phone',
      replace: true,
    });
  }
  // @ts-ignore
  if (res.code === 200) {
    user.value = res.data
  }
})




const value = ref('123');
const showKeyboard = ref(true);

const router = useRouter();
const onSubmit = async () => {
  const res = await myAxios.get("/safety-check")
  console.log("phone登录");
  // @ts-ignore
  if (res?.code === 200 && res.data) {
    router.push({
      path: '/update',
      replace: true,
    });
  } else {
  }
};

const time = ref(2* 60 * 1000);
</script>

<template>
  <div class="top">
    <div>
      <van-count-down :time="time" format="ss秒" />
    </div>
  </div>
  <div class="con">
    <!-- 密码输入框 -->
    <van-password-input
        :value="value"
        :mask="false"
        :focused="showKeyboard"
        @focus="showKeyboard = true"
    />
    <!-- 数字键盘 -->
    <van-number-keyboard
        v-model="value"
        :show="showKeyboard"
        @blur="showKeyboard = false"
    />

  </div>
  <div class="buttom"></div>

</template>

<style scoped>

</style>